const maxValue = (rule, value, callback) => {
  if (value) {
    if (value > 99999999) {return callback(new Error('最大值为99999999'))}
    else {callback ()}
  }
}

export const editFormRules = {
  columnInputTypeGood: [
    { required: true, message: '请选择类型(商品属性)', trigger: 'change' }
  ],
  columnInputTypePurchaser: [
    { required: true, message: '请选择类型(采购属性)', trigger: 'change' }
  ],
  propertyName: [
    {required: true, message: '请输入属性名称', trigger: 'blur' },
    { min: 1, max: 200, message: '最多可以输入200字符', trigger: 'blur' }
  ]
}

export const editFormOptionsRules = {
  propertyValue: [
    { required: true, message: '请输入商品属性值', trigger: 'blur' },
    { min: 1, max: 200, message: '最大极限200字符', trigger: 'blur' }
  ],
  sorts: [
    { required: true, message: '请输入排序', trigger: 'blur' },
    { validator: maxValue, trigger: 'blur' }
  ],
  valueSize: [
    { required: true, message: '请输入属性值大小', trigger: 'blur' },
    { validator: maxValue, trigger: 'blur' }
  ],
  v: [
    { required: true, message: '请选择是否有效', trigger: 'change' }
  ]
}

export const editPurchaseFormRules = {
  propertyValuePurchaser: [
    { required: true, message: '请输入商品显示属性值', trigger: 'blur' },
    { min: 1, max: 200, message: '最多可以输入200字符', trigger: 'blur' }
  ],
  propertyValueSearch: [
    { required: true, message: '请输入商品检索属性值', trigger: 'blur' },
    { min: 1, max: 200, message: '最多可以输入200字符', trigger: 'blur' }
  ],
  sorts: [
    { required: true, message: '请输入排序', trigger: 'blur' },
    { validator: maxValue, trigger: 'blur' }
  ],
  v: [
    { required: true, message: '请选择是否有效', trigger: 'change' }
  ]
}

export const editFormOptions = [
  {
    label: '输入类型(商品属性)',
    type: 'select',
    key: 'columnInputTypeGood',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
    ]
  },
  {
    label: '输入类型(采购属性)',
    type: 'select',
    key: 'columnInputTypePurchaser',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
    ]
  },
  {
    label: '中心维护商品值取值规则',
    type: 'select',
    key: 'fkItemRuleIdToCenter',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
    ]
  },
  {
    label: '供应商维护商品值取值规则',
    type: 'select',
    key: 'fkItemRuleIdToSupplier',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
    ]
  },
  {
    label: '属性名称',
    type: 'input',
    key: 'propertyName',
    span: 12,
    props: {
      placeholder: '请输入'
    }
  },
  {
    label: '商品属性前缀',
    type: 'input',
    key: 'propertyPrefix',
    span: 12,
    props: {
      placeholder: '请输入'
    }
  },
  {
    label: '商品属性后缀',
    type: 'input',
    key: 'propertySuffix',
    span: 12,
    props: {
      placeholder: '请输入'
    }
  },
  {
    label: '排序',
    type: 'number',
    key: 'sorts',
    span: 12,
    props: {
      placeholder: '请输入',
      controls: false
    }
  },
  {
    label: '商品属性字段类型',
    type: 'select',
    key: 'columnType',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
      {
        label: 'varchar',
        value: 'varchar'
      },
    ]
  },
  {
    label: '商品属性字段大小',
    type: 'input',
    key: 'columnSize',
    span: 12,
    props: {
      placeholder: '请输入',
      controls: false
    }
  },
  {
    label: '是否主要属性',
    type: 'radio',
    key: 'isMain',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  },
  {
    label: '采购人是否必选',
    type: 'radio',
    key: 'isPurchaserMust',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  },
  {
    label: '供应商是否必选',
    type: 'radio',
    key: 'isSupplierMust',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  },
  {
    label: '是否有效',
    type: 'radio',
    key: 'v',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  },
  {
    label: '属性筛选',
    type: 'radio',
    key: 'isSearch',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  },
  {
    label: '按需采购属性筛选',
    type: 'radio',
    key: 'isPurchaseSearch',
    span: 12,
    props: {
      placeholder: '请选择'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  }
]

export const editTableFormOptions = [
  {
    label: '商品属性值',
    type: 'input',
    key: 'propertyValue',
    span: 12,
    props: {
      placeholder: '请输入商品属性值'
    }
  },
  {
    label: '排序',
    type: 'number',
    key: 'sorts',
    span: 12,
    props: {
      placeholder: '请输入排序',
      controls: false
    }
  },
  {
    label: '属性值大小',
    type: 'number',
    key: 'valueSize',
    span: 12,
    props: {
      placeholder: '请输入属性值大小',
      controls: false
    }
  },
  {
    label: '是否有效',
    type: 'radio',
    key: 'v',
    span: 12,
    props: {
      placeholder: '请选择是否有效'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  }
]

export const editPurchaseTableFormOptions = [
  {
    label: '商品显示属性值',
    type: 'input',
    key: 'propertyValuePurchaser',
    span: 12,
    props: {
      placeholder: '请输入商品属性值'
    }
  },
  {
    label: '商品检索属性值',
    type: 'input',
    key: 'propertyValueSearch',
    span: 12,
    props: {
      placeholder: '请输入商品属性值'
    }
  },
  {
    label: '排序',
    type: 'number',
    key: 'sorts',
    span: 12,
    props: {
      placeholder: '请输入排序',
      controls: false
    }
  },
  {
    label: '是否有效',
    type: 'radio',
    key: 'v',
    span: 12,
    props: {
      placeholder: '请选择是否有效'
    },
    options: [
      {
        label: '1',
        text: '是'
      },
      {
        label: '0',
        text: '否'
      }
    ]
  }
]

